package com.xcity.pomelo.response;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

import com.xcity.db.entity.Employee;
import com.xcity.db.entity.Player;
import com.xcity.game.common.ItemResponse;
import com.xcity.game.employee.EmployeeService;
import com.xcity.game.employee.EmployeeUtils;
import com.xcity.game.item.ItemInfo;
import com.xcity.game.item.ItemTemplate;

import naga.x.net.impl.pomelo.PomeloMessage;
import naga.x.net.impl.pomelo.protocol.Message;

@PomeloMessage(type = Message.Type.RESPONSE)
public class EmployeeLevelUpInfoResponse extends Response {
	
	private long id;
	private int level;
	private int maxLvl;
	private List<ItemInfo> items = Collections.emptyList(); // 经验书
	
	public EmployeeLevelUpInfoResponse(int serial, Player player, Employee employee, EmployeeService service) {
		super(serial);
		this.id = employee.getId();
		this.level = employee.getLevel();
		this.maxLvl = EmployeeUtils.getMaxLevel(employee.getTemplate().getQuality());
		List<ItemTemplate> expBooks = service.configure().getCommonConfigure().getExpBooks();
		if (expBooks != null && expBooks.size() > 0) {
			this.items = new ArrayList<ItemInfo>(expBooks.size());
			for (int i = 0; i < expBooks.size(); i++) {
				int itemId = expBooks.get(i).getId();
				int count = player.getBag().countOf(itemId);
				ItemInfo item = new ItemResponse(itemId, count);
				this.items.add(item);
			}
		}
	}

	public long getId() {
		return id;
	}

	public void setId(long id) {
		this.id = id;
	}

	public int getLevel() {
		return level;
	}

	public void setLevel(int level) {
		this.level = level;
	}

	public int getMaxLvl() {
		return maxLvl;
	}

	public void setMaxLvl(int maxLvl) {
		this.maxLvl = maxLvl;
	}

	public List<ItemInfo> getItems() {
		return items;
	}

	public void setItems(List<ItemInfo> items) {
		this.items = items;
	}
	
}
